#include "Require/Init.iss"
#include "Class/${Me.ClassAbrv}.iss"

function main()
{
	Turbo 1000
	extension -require isxvg
	EA "Loading" "Wanderbot.iss"

	InjectObject Core BotCore
	;InjectObject Test1 Testing1
	;InjectObject Test2 Testing2
	InjectObject Move Movement
	InjectObject Scan Scanning
	;InjectObject Loot Looting
	;InjectObject Activate Activating
	InjectObject Avatar Character
	InjectObject Idle BotIdle
	InjectObject Action BotAction

	declare LogDir file script
	declare VGMapsDir filepath script 
	VGMapsDir:Set["${Script[Wanderbot].CurrentDirectory}/Map/"]

	call LoadGUI
	call InitializeSettings
	;BindTriggers
	;Bind togglebot f1 ToggleBot

	;Base:ClearTarget
	
	call Core.Run
}

function atexit()
{
	Move:Stop
	call StoreSettings
	call UnloadGUI
	;Bind -delete togglebot
	EA "Unloading" "Wanderbot.iss"
}

atom(global) ToggleBot()
{
	if ${Core.CurrentState} == 3
	{
		Event[CORE_EVENT_PAUSE]:Execute[FALSE]
		;UIElement[VG Wanderbot].FindUsableChild[cmdStart,commandbutton]:SetText["Pause"]
	}
	else
	{
		Event[CORE_EVENT_PAUSE]:Execute[TRUE]
		;UIElement[VG Wanderbot].FindUsableChild[cmdStart,commandbutton]:SetText["Start"]
		Move:Stop
	}
}

atom InjectObject(string VariableName, string ObjectName)
{
	declare ${VariableName} ${ObjectName} global
	EA "${ObjectName}" "Injected into Wanderbot"
	${VariableName}:Inject
}